package com.sright.bcard.cms.controller;

import com.sright.bcard.common.service.share.dto.pager.Pager;
import com.sright.bcard.common.service.share.mvcresolver.EnableLoginAuth;
import com.sright.bcard.common.service.share.dto.content.CardTemplateDTO;
import com.sright.bcard.content.share.service.TemplateService;
import com.sright.common.response.SrightResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Author: lumf
 * Date: 2020/8/13 6:02 PM
 */
@RestController
@Slf4j
public class TemplateManageController {
    @Autowired
    TemplateService templateService;

    @EnableLoginAuth
    @GetMapping("/template/list")
    public SrightResponse getTemplateList(@RequestParam(value = "keyword", required = false) String keyword,
                                          @RequestParam(value = "page") Integer pageIndex,
                                          Integer pageSize
                                          ) {


        Pager<CardTemplateDTO> pager = templateService.searchTemplateByKeyword(
                keyword,
                pageIndex, pageSize
        );
        return SrightResponse.defaultSuccess(pager);
    }
}
